<template>
	<view class="news-detail">
		<view class="title">{{news.title}}</view>
		<view class="info">
			<text>发布时间：{{news.releaseDate}}</text>
			<text>阅读次数：{{news.viewCount}}</text>
		</view>
		<view class="content">
			<!-- 使用富文本组件可以识别html内容 -->
			<rich-text :nodes="news.content"></rich-text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				news:{}
			}
		},
		onLoad(options) {
			console.log("入参数为：", options.id);
			this.getNewsDetailsById(options.id);
		},
		methods: {
			getNewsDetailsById(id){
				// 真实场景应该是调用接口获取详情信息
				this.news = {
					title: "OPPO最新款手机评测",
					releaseDate: "2021-10-22",
					viewCount: 997,
					content: "<p>如下是正文内容......</p><p>如下是正文内容......</p><p>如下是正文内容......</p><p>如下是正文内容......</p><p>如下是正文内容......</p><p>如下是正文内容......</p>"
				};
			}
		}
	}
</script>

<style lang="scss">
.news-detail {
	font-size: 30rpx;
	padding: 0 20rpx;
	.title {
		text-align: center;
		width: 710rpx;
		display: block;
		margin: 20rpx 0;
	}
	.info {
		display: flex;
		justify-content: space-between;
	}
	.content {
		text-align: left;
		margin: 20rpx 0;
	}
}
</style>
